//
//  ViewController.m
//  02-UIPopoverPresentationController
//
//  Created by J on 15/11/8.
//  Copyright © 2015年 JZJ. All rights reserved.
//

#import "ViewController.h"
#import "JZJViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UISlider *slide;
//UIPopoverController 只能运行在ipad
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.



}



- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

    JZJViewController * vc=[[JZJViewController alloc]init];
    vc.modalPresentationStyle=UIModalPresentationPopover;
    vc.popoverPresentationController.sourceView=self.slide;//管理vc的presentationcontroller是一个特殊的presentationcontroller 是一个 popoverPresentationController(继承于presentationController)
    vc.popoverPresentationController.sourceRect=self.slide.bounds;
    [self presentViewController:vc animated:YES completion:nil];
    
    
    
//    UIPopoverPresentationController * popover=[[UIPopoverPresentationController alloc]initWithPresentedViewController:vc presentingViewController:self];//当运行在ipad上时 上面的代码效果等同于这句
  
}


- (void)popover{
    
    
    JZJViewController * vc=[[JZJViewController alloc]init];//创建一个控制器
    UIPopoverController * popover=[[UIPopoverController alloc]initWithContentViewController:vc];//把控制器包装成popover控制器
    
    
    
    [popover presentPopoverFromRect:self.slide.bounds inView:self.slide permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    
    
    
}

@end
